package org.drjava.service;/**
 * Created by jiangchen on 2017/7/15.
 */

import static org.bouncycastle.asn1.x500.style.RFC4519Style.l;

import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.drjava.dao.mapper.master.CallRecordMapper;
import org.drjava.dao.model.master.CallRecord;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 陈江
 * @version 1.0
 * @email cj@51huadian.cn
 * @date 2017/7/15
 */
@Slf4j
@Service
public class CallRecordService {

  @Autowired
  private CallRecordMapper callRecordMapper;


  public CallRecord getOne(Long one){
    CallRecord callRecord = new CallRecord();
    callRecord.setId(one);
    return callRecordMapper.selectByPrimaryKey(callRecord);
  }
  public List<CallRecord> getAll(CallRecord callRecord) {
    log.info("查询CallRecord列表，请求参数{}", JSON.toJSONString(callRecord));
    if (callRecord.getPage() != null && callRecord.getRows() != null) {
      PageHelper.startPage(callRecord.getPage(), callRecord.getRows());
    }
    List<CallRecord> records = callRecordMapper.selectAll();
    log.info("查询CallRecord列表，结果{}", JSON.toJSONString(records));
    return records;
  }

  public int  putBatch(List<CallRecord> list){
    return callRecordMapper.insertList(list);
  }

}